import {HOST} from './request'
const UploadFile = function(url,uploadUrl,params){
  let formData = params?params:{};
  const app = getApp && getApp();
  return new Promise((resolve, reject) => {
    wx.uploadFile({ 
      url: HOST+(uploadUrl?uploadUrl:'/common/file/upload'), 
      filePath: url,
      name: 'file',
      formData: formData,
      header:{
        cookie:app?app.globalData.token:'',
        'Content-Type': 'multipart/form-data'
      }, 
      success (res){
        console.log(res);
        //do something
        resolve(JSON.parse(res.data).data);
      },
      fail:function(error){
        console.log(error);
        // reject(error);
      },
    })
  });
}
module.exports = {
  UploadFile:UploadFile
}